

package com.hexinfo.dmpro.script.publish.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.script.publish.entity.ScriptPublishListEntity;
import com.hexinfo.dmpro.script.publish.service.IScriptPublishListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 脚本发布清单
 *
 * @author Wang zhihao
 * @date 2023-09-13 18:17:51
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/scriptPublish/list" )
@Api(value = "scriptPublishList", tags = "脚本发布清单管理")
public class ScriptPublishListController {

    private final IScriptPublishListService scriptPublishListService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param scriptPublishList 脚本发布清单
     * WrapperEnhancer.like(scriptPublishList); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public ResponseEntity<Object> getScriptPublishListPage(Page page, ScriptPublishListEntity scriptPublishList) {
        return new ResponseEntity<>(scriptPublishListService.queryList(page,scriptPublishList), HttpStatus.OK);
    }


    /**
     * 通过id查询脚本发布清单
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public ResponseEntity<Object> getById(@PathVariable("id" ) String id) {
        return ResponseEntity.ok(scriptPublishListService.getById(id));
    }

    /**
     * 新增脚本发布清单
     * @param scriptPublishList 脚本发布清单
     * @return R
     */
    @ApiOperation(value = "新增脚本发布清单", notes = "新增脚本发布清单")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody ScriptPublishListEntity scriptPublishList) {
        return ResponseEntity.ok(scriptPublishListService.save(scriptPublishList));
    }

    /**
     * 修改脚本发布清单
     * @param scriptPublishList 脚本发布清单
     * @return R
     */
    @ApiOperation(value = "修改脚本发布清单", notes = "修改脚本发布清单")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody ScriptPublishListEntity scriptPublishList) {
        return ResponseEntity.ok(scriptPublishListService.updateById(scriptPublishList));
    }

    /**
     * 通过id删除脚本发布清单
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除脚本发布清单", notes = "通过id删除脚本发布清单")
    @DeleteMapping("/{id}" )
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(scriptPublishListService.removeById(id));
    }

}
